//
//  AMAccount.m
//  AMwb
//
//  Created by zhc on 15/12/1.
//  Copyright © 2015年 zhc. All rights reserved.
//

#import "AMAccount.h"

@interface AMAccount()<NSCoding>


@end

@implementation AMAccount

+ (instancetype)accountWithDict:(NSDictionary *)dict{

    AMAccount *account=[[self alloc]init];
    account.access_token=dict[@"access_token"];
    account.expires_in=dict[@"expires_in"];
    account.uid=dict[@"uid"];
    
    //不要再这里写，字典里没有时间，时间是自己自定义的，生成accessToken的时间
    //account.created_Time=dict[@"created_Time"];
    
    return account;


}

//归档到沙盒之前会调用这个的方法，
//目的是，在这个方法说清楚这个对象的哪些属性要写进沙盒

- (void)encodeWithCoder:(NSCoder *)enCoder

{
    
    [enCoder encodeObject:self.access_token forKey:@"access_token"];
     [enCoder encodeObject:self.expires_in forKey:@"expires_in"];
     [enCoder encodeObject:self.uid forKey:@"uid"];
    [enCoder encodeObject:self.created_Time forKey:@"created_Time"];
  
    
}
//当从沙盒中接档一个对象的时候，就会调用这个方法，这个方法说明沙盒中的属性怎解析（取出什么解析）

- (instancetype)initWithCoder:(NSCoder *)Decoder{
  //构造方法
    if (self =[super init]){
        
        self.access_token =[Decoder decodeObjectForKey:@"access_token"];
        self.expires_in =[Decoder decodeObjectForKey:@"expires_in"];
        self.uid =[Decoder decodeObjectForKey:@"uid"];
        self.created_Time =[Decoder decodeObjectForKey:@"created_Time"];
        
    
    
    }
    return  self;
    
}


@end
